﻿using Q_SMS.Response;
using Q_SMS.Sender;
using System;
using System.Collections.Generic;
using System.Text;

namespace Q_SMS
{
    public enum SMSType : int
    {
        普通短信 = 0,
        营销短信 = 1
    }
    public class SMSHelper
    {

        string _appid { set; get; }
        string _appkey { set; get; }

        public SMSHelper(string appid, string appkey)
        {
            _appid = appid;
            _appkey = appkey;
        }
        /// <summary>
        /// 普通单发短信接口，明确指定内容，如果有多个签名，请在内容中以【】的方式添加到信息内容中，否则系统将使用默认签名
        /// </summary>
        /// <param name="type">短信类型，0 为普通短信，1 营销短信</param>
        /// <param name="nationCode">国家码，如 86 为中国</param>
        /// <param name="phoneNumber">不带国家码的手机号</param>
        /// <param name="msg">信息内容，必须与申请的模板格式一致，否则将返回错误</param>
        /// <param name="extend">扩展码，可填空</param>
        /// <param name="ext">服务端原样返回的参数，可填空</param>
        /// <returns></returns>
        public SMSSingleResult Send(SMSType type, string phoneNumber, string msg, string nationCode = "86", string extend = "", string ext = "")
        {            
            return SMSSingleSender.Send(_appid, _appkey, (int)type, nationCode, phoneNumber, msg, extend, ext, "", "", new List<string>());
        }
        /// <summary>
        /// 模板短信
        /// </summary>
        /// <param name="phoneNumber">不带国家码的手机号</param>
        /// <param name="templId">模板id</param>
        /// <param name="templParams">模板参数</param>
        /// <param name="sign">签名(不填使用默认签名)</param>
        /// <param name="extend">扩展码，可填空</param>
        /// <param name="nationCode">国家码，如 86 为中国</param>
        /// <param name="ext">服务端原样返回的参数，可填空</param>
        /// <returns></returns>
        public SMSSingleResult SendWithTemplate(string phoneNumber, string templId, List<string> templParams, string sign, string extend = "", string nationCode = "86", string ext = "")
        {
            return SMSSingleSender.Send(_appid, _appkey, -1, nationCode, phoneNumber, "", extend, ext, sign, templId, templParams);
        }
        /// <summary>
        /// 普通群发
        /// </summary>
        /// <returns></returns>
        public SMSMultiResult Send(SMSType type, string nationCode, List<string> phoneNumbers, string msg, string extend, string ext)
        {
            return SMSMultiSender.Send(_appid, _appkey, (int)type, nationCode, phoneNumbers, msg, extend, ext, "", "", new List<string>());
        }
        /// <summary>
        /// 模板群发
        /// </summary>
        /// <returns></returns>
        public SMSMultiResult SendWithTemplate(String nationCode, List<string> phoneNumbers, string templId, List<string> templParams, string sign, string extend, string ext)
        {
            return SMSMultiSender.Send(_appid, _appkey, -1, nationCode, phoneNumbers, "", extend, ext, sign, templId, templParams);
        }
    }
}
